const express = require("express");
const router = express.Router();
const {
  addSalesMen,
  getSalesMen,
  delSalesMen,
  getSalesMenById,
  updateSalesMen,
} = require("../service/salesMenService");

//获取销售员数据
router.get("/getSalesMen", async (req, res, next) => {
  const data = await getSalesMen(req.query);
  console.log(111,req.query);
  res.send(data);
});

// 新增销售员
router.post("/addSalesMen", async (req, res, next) => {
  const data = await addSalesMen(req.body);
  console.log(222,req.body);
  res.send(data);
});

// 删除销售员
router.post("/delSalesMen", async (req, res, next) => {
  const data = await delSalesMen(req.body);
  console.log(333,data);
  res.send(data);
});

// 获取单个销售老哥数据 根据_id
router.get("/getSalesMenById", async (req, res, next) => {
  res.send(await getSalesMenById(req.query));
});

// 修改销售员
router.post("/updateSalesMen", async (req, res, next) => {
  res.send(await updateSalesMen(req.body));
});

module.exports = router;
